/** 
 * @(#)AuthorityInterceptor.java Mar 28, 2009
 * 
 * Copyright (c) 1995-2009 Wonders Information Co.,Ltd.
 * 1518 Lianhang Rd,Shanghai 201112.P.R.C.
 * All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of Wonders Group.
 * (Social Security Department). You shall not disclose such
 * Confidential Information and shall use it only in accordance with 
 * the terms of the license agreement you entered into with Wonders Group. 
 *
 * Distributable under GNU LGPL license by gnu.org
 */

package com.rohoo.framework.interceptor;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.wondersgroup.sse.app.Global;


public class AuthorityInterceptor extends MethodFilterInterceptor {
	
	private Log log = LogFactory.getLog(this.getClass());
	/**
	 * 
	 * @see com.opensymphony.xwork2.interceptor.MethodFilterInterceptor#doIntercept(com.opensymphony.xwork2.ActionInvocation)
	 */
	public String doIntercept(ActionInvocation invocation) throws Exception {

		ActionContext ctx = invocation.getInvocationContext();
		Map session = ctx.getSession();
		if(session.get(Global.USER_PROFILE_KEY) != null){			
			return invocation.invoke();
		}else{
			log.info(">>> no login");
			return Action.LOGIN;
		}
	}
}
